﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Elements
{
    public partial class ImageFormatDialog : Form
    {
        private string strFormat;

        public ImageFormatDialog()
        {
            InitializeComponent();
            var io = new ItemObject[6];
            io[0] = new ItemObject("JPEG(*.jpg;*.jpeg;*.jpe)", ImageFormat.Jpeg.ToString());
            io[1] = new ItemObject("TIFF(*.tif;*.tiff)", ImageFormat.Tiff.ToString());
            io[2] = new ItemObject("BMP(*.bmp)", ImageFormat.Bmp.ToString());
            io[3] = new ItemObject("PNG(*.png)", ImageFormat.Png.ToString());
            io[4] = new ItemObject("GIF(*.gif)", ImageFormat.Gif.ToString());
            io[5] = new ItemObject("WMF(*.wmf)", ImageFormat.Wmf.ToString());
            comboBox1.Items.AddRange(io);
            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember = "Value";
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            var coSelected = (ItemObject)comboBox1.SelectedItem;
            strFormat = coSelected.Value;
            DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        public string GetFormat()
        {
            return strFormat;
        }

    }

    public class ItemObject
    {
        public string Text = "", Value = "";

        public ItemObject(string text, string value)
        {
            Text = text;
            Value = value;
        }

        public override string ToString()
        {
            return Text;
        }
    }
}
